package com.lab.spring;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * Created with IntelliJ IDEA.
 * User: bsceran
 * Date: 5/21/13
 * Time: 11:15 AM
 * To change this template use File | Settings | File Templates.
 */
public class Invoker {

    public static void main(String[] args) {
//        Resource springContextResource = new ClassPathResource("springContext.xml");
//        BeanFactory factory = new XmlBeanFactory(springContextResource);
        ApplicationContext factory = new ClassPathXmlApplicationContext("springContext.xml");
        SequenceGenerator  sequenceGenerator = (SequenceGenerator) factory.getBean("sequenceGenerator-A");
        System.out.println(sequenceGenerator.getSequence());
        System.out.println(sequenceGenerator.getSequence());
        System.out.println(sequenceGenerator.getSequence());
        System.out.println("--------------------------------");

        sequenceGenerator = (SequenceGenerator) factory.getBean("sequenceGenerator-B");
        System.out.println(sequenceGenerator.getSequence());
        System.out.println(sequenceGenerator.getSequence());
        System.out.println(sequenceGenerator.getSequence());
        System.out.println("--------------------------------");

        sequenceGenerator = (SequenceGenerator) factory.getBean("sequenceGenerator2");
        System.out.println(sequenceGenerator.getSequence());
        System.out.println(sequenceGenerator.getSequence());
        System.out.println(sequenceGenerator.getSequence());

        System.out.println("--------------------------------");

        sequenceGenerator = (SequenceGenerator) factory.getBean("sequenceGenerator3");
        System.out.println(sequenceGenerator.getSequence());
        System.out.println(sequenceGenerator.getSequence());
        System.out.println(sequenceGenerator.getSequence());
    }
}
